<layout name='layout/main' />

<header class="am-header am-header-default">
	<div class="am-header-left am-header-nav">
	<a href="<{:U('Index/index')}>"><i class="am-header-icon am-icon-home"></i></a>
	</div>
	<h1 class="am-header-title">签到</h1>
	<div class="am-header-right am-header-nav">
	<a href="javascript:window.history.go(-1)"><i class="am-header-icon am-icon-reply"></i></a>
	</div>
</header>

<div class="qianTop">
	<div class="jifen">积分<span id="point"><{$_user['point']}></span></div>
	<div class="qdBtn">
		<eq name="flag" value="1">
		<button class="am-btn am-btn-default" id="signBtn">今日已签到</button>
		<else/>
		<button class="am-btn am-btn-warning" onclick="sign()" id="signBtn">签到</button>
		</eq>		
	</div>	
</div>

<div class="calendar">
	<volist name="date" id="vo">
	<li>
		<span><{$vo}></span>
		<p id="<{$vo}>">
		<?php 
		if (in_array($vo, $sign)) {
			echo '<i class="am-icon-check"></i>';
		}
		?>
		</p>
	</li>
	</volist>
</div>
<div><a href="<{:U('Lottery/index')}>"><img src="<{:RES}>/image/choujiang.jpg" alt=""></a></div>

<script>
function sign(){
	$.ajax({
		url : '<{:U('Qian/sign')}>',
    	type : 'get',
    	dataType : 'json',
	    success : function(response){
			if (response.state=='SUCCESS') {
				_alert('今日签到获得'+response.message+'个积分');
				$("#signBtn").attr('disabled','disabled').removeClass("am-btn-warning").addClass("am-btn-default").html("今日已签到");
				$("#"+response.url).html('<i class="am-icon-check"></i>');
				oldPoint = parseInt($("#point").html());
				point = parseInt(response.message);
				$("#point").html(oldPoint+point);
			}else{
				_alert(response.state);
			}
	    }
  	})
}
</script>